using System.Windows;
using System.Windows.Markup;
using Common;

namespace ProjectView.Windows
{
    public partial class PasswordValidateWindow : Window, IComponentConnector
    {
        public string Password { get; set; }

        public string InputPassword { get; set; }

        public PasswordValidateWindow()
        {
            InitializeComponent();
            passwordBoxEdit.Focus();
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            int num = 6;
            if (passwordBoxEdit.Password.Length < num)
            {
                MessageBox.Show(string.Format(Utility.GetMessage("msg_password_length_less"), num));
                passwordBoxEdit.SelectAll();
                passwordBoxEdit.Focus();
            }
            else if (!Password.Equals(passwordBoxEdit.Password))
            {
                MessageBox.Show(Utility.GetMessage("msg_password_invalid"));
                passwordBoxEdit.SelectAll();
                passwordBoxEdit.Focus();
            }
            else
            {
                InputPassword = passwordBoxEdit.Password;
                base.DialogResult = true;
                Close();
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
